/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.trumah.model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author rafaell
 */
@Entity
@Table(name = "Doador")
@Inheritance(strategy=InheritanceType.JOINED)
@NamedQueries({@NamedQuery(name = "Doador.findAll", query = "SELECT d FROM Doador d"), @NamedQuery(name = "Doador.findById", query = "SELECT d FROM Doador d WHERE d.id = :id")})
public class Doador extends Pessoa implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @OneToMany(mappedBy = "doadorId")
    private List<DoadorJuridico> doadorJuridicoList;
    @OneToMany(mappedBy = "doadorId")
    private List<DoadorFisico> doadorFisicoList;
    @JoinColumn(name = "pessoa_id", referencedColumnName = "id")
    @ManyToOne
    private Pessoa pessoaId;
    @JoinColumn(name = "endereco_id", referencedColumnName = "id")
    @ManyToOne
    private Endereco enderecoId;

    public Doador() {
    }

    public Doador(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public List<DoadorJuridico> getDoadorJuridicoList() {
        return doadorJuridicoList;
    }

    public void setDoadorJuridicoList(List<DoadorJuridico> doadorJuridicoList) {
        this.doadorJuridicoList = doadorJuridicoList;
    }

    public List<DoadorFisico> getDoadorFisicoList() {
        return doadorFisicoList;
    }

    public void setDoadorFisicoList(List<DoadorFisico> doadorFisicoList) {
        this.doadorFisicoList = doadorFisicoList;
    }

    public Pessoa getPessoaId() {
        return pessoaId;
    }

    public void setPessoaId(Pessoa pessoaId) {
        this.pessoaId = pessoaId;
    }

    public Endereco getEnderecoId() {
        return enderecoId;
    }

    public void setEnderecoId(Endereco enderecoId) {
        this.enderecoId = enderecoId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Doador)) {
            return false;
        }
        Doador other = (Doador) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "trumah.Doador[id=" + id + "]";
    }

}
